﻿using System.Text.Encodings.Web;
using Fluid;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using ZYing.LiquidThemeEngine.FileProviders;

namespace ZYing.LiquidThemeEngine.MvcSample
{
    public class ConfigureLiquidThemeEngineOptions : ConfigureOptions<LiquidThemeEngineOptions>
    {
        public ConfigureLiquidThemeEngineOptions(IWebHostEnvironment env, IMemoryCache cache, HtmlEncoder encoder) :
            base(options =>
            {
                options.FileProvider = new LiquidThemeFileProvider(env.WebRootFileProvider, "themes");
                options.TextEncoder = encoder;
                options.TemplateOptions.MemberAccessStrategy.MemberNameStrategy = MemberNameStrategies.SnakeCase;
            })
        {
        }
    }
}